package com.db;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class ReadPara {

	public JSONObject getCalcPara(){
		JSONObject obj=new JSONObject();
		InputStream is;
		try {
			is = this.getClass().getResourceAsStream("");
			String s=IOUtils.toString(is, "UTF-8");
			JSONArray jarr=JSONArray.fromObject(s);
			System.out.println(jarr);
			for(int i=0;i<jarr.size();i++){
				String name=jarr.getJSONObject(i).getString("name");
				//System.out.println();
				obj.put(name, true);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println("obj="+obj);
		return obj; 
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//new ReadPara().getCalcPara();
		InputStream is=ReadPara.class.getResourceAsStream("/config/checkval.json");
		System.out.println(is);
		try {
			String s=IOUtils.toString(is, "UTF-8");
			System.out.println(s);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
